package programmercarl.数组.C3;

class Solution {
    public static int removeElement(int[] nums, int val) {
        int i = 0, j = nums.length - 1;
        while (i <= j) {//直接做复制
            if (nums[i] == val) {
                nums[i] = nums[j];
                j--;
            }else {
                i++;
            }
        }
        return i;
    }

    public static void main(String[] args) {
        removeElement(new int[]{3,2,2,3},3);
    }
}